package com.zzr.zzrbackend.controller;

import com.zzr.zzrbackend.pojo.dto.CommonResult;
import com.zzr.zzrbackend.pojo.dto.param.GroupNameParam;
import com.zzr.zzrbackend.pojo.dto.result.*;
import com.zzr.zzrbackend.service.MessageService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.*;



@RestController
public class MessageController {

    @Resource
    private MessageService messageService;


    @RequestMapping(value = "/api/message-detail", method = RequestMethod.GET)
    public CommonResult<MessageListResult> getMessageDetailList(HttpServletRequest request, @RequestParam(value =
            "roomId") Integer roomId) {
        return messageService.getMessageDetailList(request, roomId);
    }

    @RequestMapping(value = "/api/message-num-list", method = RequestMethod.GET)
    private CommonResult<MessageNumListResult> getMessageNumList(HttpServletRequest request) {
        return messageService.getMessageListNumList(request);
    }

    @RequestMapping(value = "/api/room-members", method = RequestMethod.GET)
    private CommonResult<RoomMemberListResult> getRoomMembers(HttpServletRequest request, Integer roomId,
                                                              Integer type) {
        return messageService.getRoomMembers(request, roomId, type);
    }

    @RequestMapping(value = "/api/message-read", method = RequestMethod.POST)
    private CommonResult<NoData> setMessageRead(HttpServletRequest request, @RequestParam(value =
            "roomId") Integer roomId, @RequestParam(value = "type") Integer type) {
        return messageService.setMessageRead(request, roomId, type);
    }

    @RequestMapping(value = "/api/message/user-sig", method = RequestMethod.GET)
    private CommonResult<UserSigResult> getUserSig(HttpServletRequest request) {
        return messageService.getUserSig(request);
    }

    @RequestMapping(value = "/api/message-group-detail", method = RequestMethod.GET)
    CommonResult<MessageGroupResultList> getMessageGroupDetailList(HttpServletRequest request, Integer roomId) {
        return messageService.getMessageGroupDetailList(request, roomId);
    }

    @RequestMapping(value = "/api/group-message/name", method = RequestMethod.POST)
    private CommonResult<NoData> setGroupName(HttpServletRequest request, @RequestBody GroupNameParam groupNameParam) {
        return messageService.setGroupName(request, groupNameParam);
    }

    @RequestMapping(value = "/api/group-message", method = RequestMethod.GET)
    CommonResult<GroupDetailResult> getGroup(HttpServletRequest request, Integer roomId) {
        return messageService.getGroup(request, roomId);
    }

    @RequestMapping(value = "/api/message/single-list", method = RequestMethod.GET)
    CommonResult<SingleListResult> getSingleList(HttpServletRequest request) {
        return messageService.getSingleList(request);
    }

    @RequestMapping(value = "/api/message/single-chat", method = RequestMethod.POST)
    private CommonResult<RoomIdResult> setSingleChat(HttpServletRequest request,
                                                     @RequestParam(value = "toUserId") Integer toUserId) {
        return messageService.setSingleChat(request, toUserId);
    }
}
